package com.dd.common.dto.user;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Email;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;

@Schema(description = "用户更新DTO")
@Data
public class UserUpdateDTO implements java.io.Serializable {

    @NotNull(message = "用户ID不能为空")
    @Schema(description = "用户ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
    @Min(value = 1, message = "ID必须是正整数")
    private Long id;

    @Schema(description = "昵称", example = "帅到被人砍")
    private String nickname;
    @Schema(description = "真实姓名", example = "柳如烟")
    private String realName;
    @Schema(description = "性别：0-未知 1-男 2-女", example = "1")
    @Range(min = 0, max = 2, message = "性别只能是0-未知 1-男 2-女")
    private Integer gender;

    @Schema(description = "个性签名", example = "今天吃什么？")
    @Length(max = 100, message = "个性签名长度不能超过100个字符")
    private String signature;

    /**
     * 注意：LocalDateTime 是日期 + 时间，LocalDate 是只能是日期
     */
    @Schema(description = "生日", example = "1999-01-01")
//    @Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$", message = "生日格式不正确") 而@Pattern注解只能用于String类型
    private LocalDate birthday;

    @Schema(description = "邮箱", example = "user@example.com")
    @Email(message = "邮箱格式不正确")
    private String email;
    @Schema(description = "手机号码", example = "+8613812345678")
    @Pattern(regexp = "^\\+?[0-9]{10,15}$", message = "手机号格式不正确，支持国际格式")
    private String phone;

    @Schema(description = "头像", example = "https://example.com/avatar.jpg")
    private String avatar;

}
